// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

Vue.config.productionTip = false;
//elementUi
import ElementUi from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUi);
//引入工具函数
import untils from './assets/untils/untils';
import './assets/js/common/common';
//common css
import './assets/css/base.css';
import './assets/css/index.css';
import './assets/css/components.css';
import 'animate.css'
//全局定义过滤器
import filters from './filters/index';

Object.keys(filters).forEach((key) => {
  Vue.filter(key, filters[key]);
});
//状态管理
import store from './store';

//引入loading组件
// import loading from './loading'
// Vue.use(loading);

//图片懒加载
import VueLazyLoad from 'vue-lazyload'

Vue.use(VueLazyLoad, {
  error: './static/error.png',
  loading: require('./assets/images/loading-list.gif')
});


//轮播图插件
import VueSwiper from 'vue-awesome-swiper';
import './assets/css/swiper.min.css'

Vue.use(VueSwiper);
router.beforeEach((to, from, next) => {
  let user = untils.getLocalStorage('token');
  next();
  if (to.name != 'test' && to.name != 'login' && to.name != 'reg') {
    if (!user) {
      router.push({path: '/login'})
    }
  }
});


var app = new Vue({
  el: '#app',
  render: h => h(App),
  router,
  store,
  data: {
    showLoading: false,
    showHead: true
  }

});


